<%@ page language="java"
    import="com.gorge4j.user.*,com.gorge4j.user.constant.*,com.gorge4j.user.dto.*,com.gorge4j.user.vo.*,com.gorge4j.user.constant.*,java.util.*"
    contentType="text/html; charset=utf-8" pageEncoding="utf-8"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id="deleteVO" class="com.gorge4j.user.dto.DeleteDTO" scope="page" />
<jsp:useBean id="businessOperationBean" class="com.gorge4j.user.BusinessOperationBean" scope="page" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>删除用户</title>
</head>
<body>
    <%
        // 通过session来控制访问的权限，只有管理员用户才可以查看用户列表
        UserSessionDTO userSession = (UserSessionDTO) session.getAttribute("userSession");
        try {
            if (userSession == null || !("admin".equals(userSession.getName())
                    && UserTypeConstant.ADMIN.equals(userSession.getType())) || !userSession.getIsLogin()) {
                response.sendRedirect("login.jsp");
            }
        } catch (Exception e) {
            response.sendRedirect("login.jsp");
        }

        try {
            DeleteDTO deleteDTO2 = new DeleteDTO();
            deleteDTO2.setId(Integer.valueOf(request.getParameter("id")));
            businessOperationBean.setDeleteDTO(deleteDTO2);
            ResponseVO respVO = businessOperationBean.delete();
            if (respVO != null && !respVO.getCode().equals(ResponseConstant.SUCCESS)) {
    %>
    <jsp:forward page="view.jsp" />
    <%
        } else {
                out.println(respVO.getMessage());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    %>
</body>
</html>